With development of microprocessors and electronic mobile terminal operating systems, electronic mobile terminals (such as a smartphone and a tablet computer) are widely used, and application functions designed for the electronic mobile terminals are increasingly powerful. Specific memory resources need to be occupied when any application program in an electronic mobile terminal runs. Therefore, though an application with abundant functions improves user experience of the electronic mobile terminal, more memory resources need to be occupied. In all existing electronic mobile terminals, a dynamic random access memory (DRAM) is used as a memory. A DRAM capacity increase can meet a requirement of the application program for memory resources to some extent. However, the DRAM capacity increase may cause a cost increase of the electronic mobile terminal. In addition, power consumption of the DRAM is high, and the power consumption may account for up to 30% of entire power consumption of an operating system. When the DRAM serves as a memory of the electronic mobile terminal, power consumption of the electronic mobile terminal is high.
Based on the foregoing problem, currently, a manner in which a swap partition is set in the operating system may further be to relieve memory pressure. For example, an Android operating system is based on an operating system of a Linux kernel, and the Linux kernel provides a method for resolving a problem of memory resource insufficiency by using a swap partition. An existing Swap mechanism may use a new byte-addressable nonvolatile memory (NVM) as a Swap partition. The Swap partition is generally divided into page slots for management. A size of each page slot equals a size of a memory page, and this is convenient for storing a memory page that is replaced from a memory. When memory resources in the electronic mobile terminal are insufficient, the operating system may store some less frequently used memory pages into the swap partition. In this way, the less frequently used memory pages no longer occupy the memory resources, thereby reducing memory occupation.
Because an NVM can be erased and written for a limited quantity of times, technologies such as consumption balance need to be used to distribute write operations to each NVM page slot as evenly as possible, so as to maximize a lifetime of the NVM. In an existing consumption balance technology, two data structures are maintained in an operating system: a linked list storing a free page slot and a min heap storing all page slots and sorting them by their ages. When a memory of a mobile terminal is insufficient, and an inactive memory page needs to be stored into an NVM swap partition, an age of a page slot of a linked list head needs to be compared with an age of a page slot of a min heap top, so as to store the inactive page of the memory into a page slot with a smaller age. However, when the page slot of the min heap top is used and has a relatively small age, data of the page slot of the min heap top further needs to be copied to the page slot of the linked list head, and then the page slot of the min heap top can be used. This method always ensures that an NVM page slot with a smaller age is used to store a memory page, thereby achieving consumption balance.
By using the foregoing technical solution, extra storage space needs to be created in an electronic mobile terminal to store an age of each NVM page slot. This causes system resource waste and system performance deterioration. In addition, an age change of any NVM page slot causes re-sorting of all NVM page slots in a min heap, and further increases system overheads. Moreover, when the foregoing less frequently used memory page needs to be re-executed, an operating system replaces the less frequently used memory page into a memory again. Consequently, data is frequently exchanged and is written for multiple times. This further causes problems that process running time is affected and a lifetime of a swap partition is affected.
It may be seen that, currently, the following problems exist during process running: a process running speed is low, a lifetime of a swap partition is short, system resources are wasted, and system performance is poor.